#pragma once
#include <vector>
#include "GLMath2DApplication.h"

namespace OpenGLWrapper
{
	class GLFunction2DGraph : public GLMath2DApplication
	{
	protected:

		std::vector<Color> _graphsColors;
		std::vector<int> _numGraphs;
		std::vector<std::vector<double>> _graphsX;
		std::vector<std::vector<double>> _graphsY;

		std::vector<double> _linesX;
		std::vector<double> _linesY;
		std::vector<Color> _linesColors;

		std::vector<double> _pointsX;
		std::vector<double> _pointsY;
		std::vector<Color> _pointsColors;

		char _currentDisplayedPoint[1024];
		double _textX, _textY;

	public:
		GLFunction2DGraph();
		virtual ~GLFunction2DGraph();

		bool virtual Init();
		void virtual Prepare(float dt);
		void virtual Render();
		void virtual OnMathRender();
		void virtual Shutdown();
		void virtual OnResize(int width, int height);
		void virtual OnMouseDown(int button, int x, int y);
		void virtual OnMouseMove(int x, int y);

		void AddFunction(double(*f)(double x), double sx, double ex, double step, Color color, bool reverse = false);
		void AddLine(double sx, double sy, double ex, double ey, Color color);
		void AddPoint(double sx, double sy, Color color);

	private:
		void RenderFunctions();
		void RenderLines();
		void RenderPoints();
	};
}

